package com.yohann.boot.controller;

import com.yohann.boot.common.annotation.LogRecordable;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

/**
 * @author Yeung Wah
 * @since 2022/1/4
 */
@RestController
public class LogTestController {
    @LogRecordable("测试日志记录")
    @GetMapping("/log")
    public String log(@CookieValue(value = "blank", required = false) Cookie cookie, HttpServletRequest request, String name) {
        return "返回值是:" + name;
    }

    @LogRecordable("测试日志异常")
    @GetMapping("/log2")
    public String log2(String name) {
        throw new RuntimeException("运行时异常");
    }
}